package com.ac.cv.client.menu;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.user.client.ui.TreeItem;

/**
 * A label to set in a {@link TreeItem} which open the treeitem when clicked
 * @author CHATELLIER
 *
 */
public class MenuMainLabel extends ClickableLabel{

	private TreeItem item;
	
	public MenuMainLabel(final TreeItem item){
		super();
		this.item = item;
	}

	public void setItem(TreeItem item) {
		this.item = item;
	}

	public TreeItem getItem() {
		return item;
	}

	@Override
	public void onClick(ClickEvent event) {		
		super.onClick(event);
		item.setState(!item.getState());
	}

	@Override
	public void onSelect() {
		this.getTreeParent().getTree().setSelectedItem(this.getTreeParent());
		item.setState(true);
	}

	@Override
	public int getId() {
		return -1;
	}

	@Override
	public boolean isMainKeyWord() {
		return false;
	}	
}
